Completed
Push — master ( 89e41e...aeed75 )
by Yannick
67:19 queued 32:53
created

map.common.js ➔ clickDisplayWeatherStation   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
nop 1
1
function getCookie(cname) {
2
    var name = cname + "=";
3
    var ca = document.cookie.split(';');
4
    for(var i=0; i<ca.length; i++) {
5
	var c = ca[i];
6
	while (c.charAt(0)==' ') c = c.substring(1);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
7
	if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
8
    }
9
    return "";
10
}
11
12
function delCookie(cname) {
13
    document.cookie = cname + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
14
}
15
16
function createCookie(name, value, days) {
17
    var date, expires;
18
    if (days) {
19
        date = new Date();
20
        date.setTime(date.getTime()+(days*24*60*60*1000));
21
        expires = "; expires="+date.toGMTString();
22
    } else {
23
        expires = "";
24
    }
25
    document.cookie = name+"="+value+expires+"; path=/";
26
}
27
28
function mapType(selectObj) {
29
    var idx = selectObj.selectedIndex;
30
    var atype = selectObj.options[idx].value;
31
    var type = atype.split('-');
32
    document.cookie =  'MapType='+type+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'
33
    if (type[0] == 'Mapbox') {
34
	document.cookie =  'MapType='+type[0]+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'
35
	document.cookie =  'MapTypeId='+type[1]+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'
36
    } else {
37
	document.cookie =  'MapType='+atype+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'
38
    }
39
    window.location.reload();
40
}
41
42
function terrainType(selectObj) {
43
    var idx = selectObj.selectedIndex;
44
    var atype = selectObj.options[idx].value;
45
    var type = atype.split('-');
46
    document.cookie =  'MapTerrain='+type+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'
47
    window.location.reload();
48
}
49
50
function sattypes(selectObj) {
51
    var sattypes = [], sattype;
52
    for (var i=0, len=selectObj.options.length; i< len;i++) {
53
	sattype = selectObj.options[i];
54
	if (sattype.selected) {
55
	    sattypes.push(sattype.value);
56
	}
57
    }
58
    //document.cookie =  'sattypes='+sattypes.join()+'; expires=<?php print date("D, j M Y G:i:s T",mktime(0, 0, 0, date("m")  , date("d")+2, date("Y"))); ?>; path=/'
59
    createCookie('sattypes',sattypes.join(),2);
60
    updateSat();
61
}
62
function airlines(selectObj) {
63
    var airs = [], air;
64
    for (var i=0, len=selectObj.options.length; i< len;i++) {
65
	air = selectObj.options[i];
66
	if (air.selected) {
67
	    airs.push(air.value);
68
	}
69
    }
70
    //document.cookie =  'filter_Airlines='+airs.join()+'; expires=<?php print date("D, j M Y G:i:s T",mktime(0, 0, 0, date("m")  , date("d")+2, date("Y"))); ?>; path=/'
71
    createCookie('filter_Airlines',airs.join(),2);
72
}
73
function airlinestype(selectObj) {
74
    var idx = selectObj.selectedIndex;
75
    var airtype = selectObj.options[idx].value;
76
    //document.cookie =  'filter_airlinestype='+airtype+'; expires=<?php print date("D, j M Y G:i:s T",mktime(0, 0, 0, date("m")  , date("d")+2, date("Y"))); ?>; path=/'
77
    createCookie('filter_airlinestype',airtype,2);
78
}
79
function alliance(selectObj) {
80
    var idx = selectObj.selectedIndex;
81
    var alliance = selectObj.options[idx].value;
82
    //document.cookie =  'filter_alliance='+alliance+'; expires=<?php print date("D, j M Y G:i:s T",mktime(0, 0, 0, date("m")  , date("d")+2, date("Y"))); ?>; path=/'
83
    createCookie('filter_alliance',alliance,2);
84
}
85
function identfilter() {
86
    var ident = $("#identfilter").value;
87
    //document.cookie =  'filter_ident='+ident+'; expires=<?php print date("D, j M Y G:i:s T",mktime(0, 0, 0, date("m")  , date("d")+2, date("Y"))); ?>; path=/'
88
    createCookie('filter_ident',ident,2);
89
}
90
function mmsifilter() {
91
    var ident = $("#mmsifilter").value;
92
    //document.cookie =  'filter_ident='+ident+'; expires=<?php print date("D, j M Y G:i:s T",mktime(0, 0, 0, date("m")  , date("d")+2, date("Y"))); ?>; path=/'
93
    createCookie('filter_mmsi',ident,2);
94
}
95
function removefilters() {
96
    // Get an array of all cookie names (the regex matches what we don't want)
97
    var cookieNames = document.cookie.split(/=[^;]*(?:;\s*|$)/);
98
    // Remove any that match the pattern
99
    for (var i = 0; i < cookieNames.length; i++) {
100
    if (/^filter_/.test(cookieNames[i])) {
101
        document.cookie = cookieNames[i] + '=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/';
102
        }
103
    }
104
    window.location.reload();
105
}
106
function sources(selectObj) {
107
    var sources = [], source;
108
    for (var i=0, len=selectObj.options.length; i< len;i++) {
109
	source = selectObj.options[i];
110
	if (source.selected) {
111
	    sources.push(source.value);
112
	}
113
    }
114
    //document.cookie =  'filter_Sources='+sources.join()+'; expires=<?php print date("D, j M Y G:i:s T",mktime(0, 0, 0, date("m")  , date("d")+2, date("Y"))); ?>; path=/';
115
    createCookie('filter_Sources',sources.join(),2);
116
}
117
118
119
function show2D() {
120
    //document.cookie =  'MapFormat=2d; expires=<?php print date("D, j M Y G:i:s T",mktime(0, 0, 0, date("m")  , date("d")+2, date("Y"))); ?>; path=/';
121
    createCookie('MapFormat','2d',10);
122
    window.location.reload();
123
}
124
function show3D() {
125
    //document.cookie =  'MapFormat=3d; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'
126
    createCookie('MapFormat','3d',10);
127
    window.location.reload();
128
}
129
function clickPolar(cb) {
130
    document.cookie =  'polar='+cb.checked+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'
131
    window.location.reload();
132
}
133
function clickDisplayAirports(cb) {
134
    document.cookie =  'displayairports='+cb.checked+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'
135
    window.location.reload();
136
}
137
function clickDisplayISS(cb) {
138
    document.cookie =  'displayiss='+cb.checked+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'
139
    updateSat();
140
}
141
function clickDisplayMinimap(cb) {
142
    document.cookie =  'displayminimap='+cb.checked+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'
143
    window.location.reload();
144
}
145
function clickVATSIM(cb) {
146
    //document.cookie =  'filter_ShowVATSIM='+cb.checked+'; expires=<?php print date("D, j M Y G:i:s T",mktime(0, 0, 0, date("m")  , date("d")+2, date("Y"))); ?>; path=/';
147
    createCookie('filter_ShowVATSIM',cb.checked,2);
148
}
149
function clickIVAO(cb) {
150
     //document.cookie =  'filter_ShowIVAO='+cb.checked+'; expires=<?php print date("D, j M Y G:i:s T",mktime(0, 0, 0, date("m")  , date("d")+2, date("Y"))); ?>; path=/';
151
     createCookie('filter_ShowIVAO',cb.checked,2);
152
}
153
function clickphpVMS(cb) {
154
    //document.cookie =  'filter_ShowVMS='+cb.checked+'; expires=<?php print date("D, j M Y G:i:s T",mktime(0, 0, 0, date("m")  , date("d")+2, date("Y"))); ?>; path=/';
155
    createCookie('filter_ShowVMS',cb.checked,2);
156
}
157
function clickSBS1(cb) {
158
    //document.cookie =  'filter_ShowSBS1='+cb.checked+'; expires=<?php print date("D, j M Y G:i:s T",mktime(0, 0, 0, date("m")  , date("d")+2, date("Y"))); ?>; path=/';
159
    createCookie('filter_ShowSBS1',cb.checked,2);
160
}
161
function clickAPRS(cb) {
162
    //document.cookie =  'filter_ShowAPRS='+cb.checked+'; expires=<?php print date("D, j M Y G:i:s T",mktime(0, 0, 0, date("m")  , date("d")+2, date("Y"))); ?>; path=/';
163
    createCookie('filter_ShowAPRS',cb.checked,2);
164
}
165
function clickDisplayGroundStation(cb) {
166
    createCookie('show_GroundStation',cb.checked,2);
167
    window.location.reload();
168
}
169
function clickDisplayWeatherStation(cb) {
170
    createCookie('show_WeatherStation',cb.checked,2);
171
    window.location.reload();
172
}
173
function clickDisplayLightning(cb) {
174
    createCookie('show_Lightning',cb.checked,2);
175
    window.location.reload();
176
}
177
function clickDisplayFires(cb) {
178
    createCookie('show_Fires',cb.checked,2);
179
    window.location.reload();
180
}
181
function unitdistance(selectObj) {
182
    var idx = selectObj.selectedIndex;
183
    var unit = selectObj.options[idx].value;
184
    document.cookie =  'unitdistance='+unit+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/';
185
}
186
function unitspeed(selectObj) {
187
    var idx = selectObj.selectedIndex;
188
    var unit = selectObj.options[idx].value;
189
    document.cookie =  'unitspeed='+unit+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/';
190
}
191
function unitaltitude(selectObj) {
192
    var idx = selectObj.selectedIndex;
193
    var unit = selectObj.options[idx].value;
194
    document.cookie =  'unitaltitude='+unit+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/';
195
}
196